﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using ProjManagSolution.pmMyWebService;

namespace ProjManagSolution
{
    public partial class InviteMember : ChildWindow
    {
        protected pmWebServiceClient ws = new pmWebServiceClient();
        // List of auto collection
        //List<user> teamMember = new List<user>();
        List<MemberEmail> listEmail = new List<MemberEmail>();

        public InviteMember(List<user> teamMember_in)
        {
            InitializeComponent();

            //get team member list
          //  teamMember = teamMember_in;


            // Add items into collection;
            AddCollectionTeamMember(teamMember_in);
            
            // Bind datacontext
            autoboxEmail.DataContext = listEmail;
        }

        //add items to collection
        private void AddCollectionTeamMember(List<user> teamMember_in)
        {
            for (int i = 0; i < teamMember_in.Count; ++i)
            {
                listEmail.Add(new MemberEmail() { 
                    m_Email = teamMember_in[i].user_email,
                    m_ID = teamMember_in[i].user_id.ToString()
                });
            }
        }

        protected bool Input_Validate()
        {
            if (autoboxEmail.SelectedItem == null)
            {
                MessageBox.Show("Please choose a user!");
                return false;
            }
            return true;
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            if(Input_Validate())
                this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }

        
    }
}

